package im.xz.cn.xiareviewer;

import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.io.IOException;

public final class XiaReviewer extends JavaPlugin {

    @Override
    public void onEnable() {
        getConfig().options().copyDefaults();
        saveDefaultConfig();

        boolean force = getConfig().getBoolean("force");
        String PromptSystem = getConfig().getString("promptSystem");
        if (!force & containsSpecialChars(PromptSystem)) {
            System.out.print("xiaReviewer :");
            System.out.println("警告：系统提示词包含英文特殊字符！这可能会使api获取出现问题，因此xiaReviewer已自动关闭。");
            System.out.println("如何解决？请将其中的英文字符替换为中文字符即可。");
            System.out.println("如果你确信你的提示词不会发送错误，请设置force为true，然后将跳过字符检查。");
            getServer().getPluginManager().disablePlugin(this);
        }
        getServer().getPluginManager().registerEvents(new chat(), this);
        System.out.println("XiaReviewer is enabled");
    }

    @Override
    public void onDisable() {
        saveDefaultConfig();
        System.out.println("XiaReviewer is disabled");
    }
    private static boolean containsSpecialChars(String str) {
        String specialChars = "\"'";
        for (int i = 0; i < specialChars.length(); i++) {
            if (str.indexOf(specialChars.charAt(i)) != -1) {
                return true;
            }
        }
        return false;
    }
}
